package com.pubinfo.passbook.common.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.pubinfo.passbook.common.handler.engine.ComputeParamListTypeHandler;
import com.pubinfo.passbook.common.model.dto.engine.EngineDescription;
import com.pubinfo.passbook.common.model.http.engine.ComputeParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Collection;

/**
 * 变量占位符
 *
 * @author zhouch
 * @date 2021/12/14 10:13
 */
@TableName(autoResultMap = true)
@Data
@NoArgsConstructor
@ApiModel("公式占位符")
public class TEnginePlaceholderEquation {

    @TableId(type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("公式名称")
    @NotBlank(message = "公式名称不能为空")
    private String name;

    /**
     * 公式体
     */
    @ApiModelProperty("公式体")
    @NotBlank(message = "公式体不能为空")
    private String body;

    /**
     * 计算链类型
     */
    @ApiModelProperty(EngineDescription.COMPUTE_CHAIN_TYPE)
    @NotBlank(message = "计算链类型不能为空")
    private String chainType;

    /**
     * 参数体
     */
    @TableField(typeHandler = ComputeParamListTypeHandler.class)
    @ApiModelProperty("参数体")
    @NotNull(message = "计算参数体如果不需要则为空数组")
    private Collection<ComputeParam> paramList;

    @ApiModelProperty("描述")
    @NotBlank(message = "计算链描述不能为空")
    private String description;

    @ApiModelProperty("前端表达式生成器元数据")
    private String meta;
}
